package com.ggsd.mytestwork.controller;

import com.ggsd.mytestwork.entity.ResponseMessage;
import com.ggsd.mytestwork.entity.User;
import com.ggsd.mytestwork.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: DingZhen
 * @Data:2025-11-13 01:17
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;


    //增删改查
    @PostMapping
    public ResponseMessage add(@RequestBody User user){
        userService.add(user);
        return ResponseMessage.success("null");
    }

    @GetMapping("/{id}")
    public ResponseMessage getUser(@PathVariable Integer id){
        User userNew = userService.getUser(id);
        return ResponseMessage.success(userNew);
    }
}
